home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / CLOBSH.PAK / STRNG.H < prev   
C/C++ Source or Header  |  1997-05-06  |  3KB  |  92 lines

  1. /*------------------------------------------------------------------------*/
  2. /*                                                                        */
  3. /*  STRNG.H                                                               */
  4. /*                                                                        */
  5. /*  Copyright Borland International 1991, 1993                            */
  6. /*  All Rights Reserved                                                   */
  7. /*                                                                        */
  8. /*------------------------------------------------------------------------*/
  9.  
  10. #if !defined( _STRNG_H )
  11. #define _STRNG_H
  12.  
  13. #define BI_OLDNAMES
  14.  
  15. #if !defined( __STRING_H )
  16. #include <string.h>
  17. #endif  // __STRING_H
  18.  
  19. #if !defined( __CLSTYPES_H )
  20. #include "classlib\obsolete\ClsTypes.h"
  21. #endif  // __CLSTYPES_H
  22.  
  23. #if !defined( __SORTABLE_H )
  24. #include "classlib\obsolete\Sortable.h"
  25. #endif  // __SORTABLE_H
  26.  
  27. #if !defined( __CHECKS_H )
  28. #include <checks.h>
  29. #endif  // __CHECKS_H
  30.  
  31. #if !defined( __CSTRING_H )
  32. #include <cstring.h>
  33. #endif
  34.  
  35. #pragma option -Vo-
  36. #if defined( __BCOPT__ ) && !defined( __FLAT__ ) && !defined( _ALLOW_po )
  37. #pragma option -po-
  38. #endif
  39.  
  40. _CLASSDEF(ostream)
  41. _CLASSDEF(String)
  42.  
  43. class _CLASSTYPE String : public Sortable
  44. {
  45.  
  46. public:
  47.  
  48.     String() {}
  49.     String( const _TCHAR _FAR *str ) : strng(str) {}
  50.     String( const _TCHAR _FAR *str, unsigned N ) : strng(str,N) {}
  51.     String( unsigned n, _TCHAR c = ' ' ) : strng( c, n ) {}
  52.     String( const String _FAR &str ) : strng(str.strng) {}
  53.     virtual ~String() {}
  54.  
  55.     String& operator = ( const String _FAR &str )
  56.         { strng = str.strng; return *this; }
  57.     operator const _TCHAR _FAR *() const
  58.         { return strng.c_str(); }
  59.  
  60.     virtual int isEqual( const Object _FAR &o ) const
  61.         { return strng == ((const String _FAR &)o).strng; }
  62.     virtual int isLessThan( const Object _FAR &o ) const
  63.         { return strng < ((const String _FAR &)o).strng; }
  64.  
  65.     virtual classType isA() const
  66.         {
  67.         return stringClass;
  68.         }
  69.  
  70.     virtual _TCHAR _FAR *nameOf() const
  71.         {
  72.         return "String";
  73.         }
  74.  
  75.     virtual hashValueType hashValue() const
  76.         { return strng.hash(); }
  77.     virtual void printOn( ostream _FAR &os ) const
  78.         { os << strng; }
  79.  
  80. private:
  81.  
  82.     BI_String strng;
  83.  
  84. };
  85.  
  86. #if defined( __BCOPT__ ) && !defined( __FLAT__ ) && !defined( _ALLOW_po )
  87. #pragma option -po.
  88. #endif
  89. #pragma option -Vo.
  90.  
  91. #endif
  92.